#pragma once
#include "PhysicsObjects.h"
#include "ParticleSystem.h"

class BaseMissile : public PhysicsBox
{
private:
	float FuseTime;
	float CurrentTime;
	//D3DXVECTOR3 Angles;
	float MaxFuel;
	float Mass;
	float FuelLeft;
	float Thrust;	//in units per second
	D3DXVECTOR3 AngledThrust;
	float FuelConsumptionRate; //in units per second
	bool Activated;
	bool IsExploded;
	
	//Needs a particle trail
	MissileTrail *Trail;
	Explosion *MainExplosion;

	D3DXMATRIX RotationMatrix;

public:
	BaseMissile();
	BaseMissile(IDirect3DDevice9 *nDevice);
	BaseMissile(IDirect3DDevice9 *nDevice, D3DXVECTOR3 nPosition, D3DXVECTOR3 nVelocity);
	BaseMissile(IDirect3DDevice9 *nDevice, D3DXVECTOR3 nPosition, D3DXVECTOR3 nVelocity,
			    float StartingFuel, float FuelRate, float nThrust, float nMass, float nFuseTime);
	~BaseMissile();

	void DeactivateMissile( void );
	void ActivateMissile( float dt );
	bool IsActive( void );
	bool HasFuelLeft(void );
	bool GetIsExploded( void );
	bool GetOldActive( void );
	void Reset( void );

	void SetAngles(D3DXVECTOR3 nAngles);
	void SetAngles(float nX, float nY, float nZ);
	void SetWVPMatrix(const D3DXMATRIX &Matrix);
	void SetEyePosition(const D3DXVECTOR3 &nVector);

	D3DXVECTOR3 GetAngles( void );

	void Explode( void );

	virtual void Update(float dt);
	virtual void Render( void );

	virtual void onLostDevice( void );
	virtual void onResetDevice( void );
};